/**
 * Copyright © 2001-2010 iSoftStone Information Technology ( Group ) Co., Ltd. All rights reserved.
 */
package com.toft.widgets.workflow.model;

import java.io.Serializable;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;

import org.apache.commons.lang.StringUtils;

import com.toft.widgets.workflow.adpater.WorkflowQueryAdapter;
import com.toft.widgets.workflow.service.WorkflowFacade;
import com.toft.widgets.workflow.utils.ConstantUtil;

/**
 * 流程历史信息
 * 
 * @ProcessHistoryInfo.java
 * @author: lllianga@isoftstone.com
 * @date: 2010-10-8
 */

public class ProcessHistoryInfo implements Serializable {

	private static final long serialVersionUID = -4962524172436818397L;

	private String activityName;
	private String businessType;
	private String businessName;
	private String businessSN;
	private String businessRecordId;
	private String assignee;
	private String agentId;
	private Date startTime;
	private Date endTime;
	private String commentType = "";
	private String commentContent = "";
	private String message;
	private String agencyId;
	private String departmentId;
	private String executionId;
	private String transitionName;
	private String imagePath;

	public String getImagePath() {
		if (StringUtils.isEmpty(assignee) || StringUtils.isNotEmpty(agentId)) {
			return "";
		}
		Map conditions = new HashMap();
		conditions.put("conn", WorkflowFacade.getConnection());
		conditions.put(ConstantUtil.AGENCY_ID, agencyId);
		conditions.put(ConstantUtil.DEPARTMENT_ID, departmentId);
		conditions.put("code", assignee);
		return WorkflowQueryAdapter.getInstance().getUserImageByCode(conditions);
	}

	public void setImagePath(String imagePath) {
		this.imagePath = imagePath;
	}

	public String getBusinessType() {
		return businessType;
	}

	public void setBusinessType(String businessType) {
		this.businessType = businessType;
	}

	public String getBusinessName() {
		return businessName;
	}

	public void setBusinessName(String businessName) {
		this.businessName = businessName;
	}

	public String getBusinessSN() {
		return businessSN;
	}

	public void setBusinessSN(String businessSN) {
		this.businessSN = businessSN;
	}

	public String getBusinessRecordId() {
		return businessRecordId;
	}

	public void setBusinessRecordId(String businessRecordId) {
		this.businessRecordId = businessRecordId;
	}

	public String getActivityName() {
		return activityName;
	}

	public void setActivityName(String activityName) {
		this.activityName = activityName;
	}

	public String getAssignee() {
		if (StringUtils.isEmpty(assignee)) {
			return "";
		}
		return assignee;
	}

	public String getAssigneeName() {
		if (StringUtils.isEmpty(assignee) || StringUtils.isNotEmpty(agentId)) {
			return "";
		}
		Map conditions = new HashMap();
		conditions.put("conn", WorkflowFacade.getConnection());
		conditions.put(ConstantUtil.AGENCY_ID, agencyId);
		conditions.put(ConstantUtil.DEPARTMENT_ID, departmentId);
		conditions.put("code", assignee);
		return WorkflowQueryAdapter.getInstance().getUserNameByCode(conditions);
	}

	public void setAssignee(String assignee) {
		this.assignee = assignee;
	}

	public String getAgentId() {
		if (StringUtils.isEmpty(agentId)) {
			return "";
		}
		return agentId;
	}

	public String getAgentIdName() {
		if (StringUtils.isEmpty(agentId)) {
			return "";
		}
		Map conditions = new HashMap();
		conditions.put("conn", WorkflowFacade.getConnection());
		conditions.put(ConstantUtil.AGENCY_ID, agencyId);
		conditions.put(ConstantUtil.DEPARTMENT_ID, departmentId);
		conditions.put("code", agentId);
		return WorkflowQueryAdapter.getInstance().getUserNameByCode(conditions);
	}

	public void setAgentId(String agentId) {
		this.agentId = agentId;
	}

	public Date getStartTime() {
		return startTime;
	}

	public void setStartTime(Date startTime) {
		this.startTime = startTime;
	}

	public Date getEndTime() {
		return endTime;
	}

	public void setEndTime(Date endTime) {
		this.endTime = endTime;
	}

	public String getCommentType() {
		if (message != null && message.indexOf(ConstantUtil.STR_SEPARATOR) != -1) {
			String[] strArray = message.split("\\" + ConstantUtil.STR_SEPARATOR);
			if (strArray.length == 2) {
				commentType = strArray[0];
			} else if (strArray.length == 1) {
				commentType = strArray[0];
			}
		}
		return commentType;
	}

	public void setCommentType(String commentType) {
		this.commentType = commentType;
	}

	public String getCommentContent() {
		if (message != null && message.indexOf(ConstantUtil.STR_SEPARATOR) != -1) {
			String[] strArray = message.split("\\" + ConstantUtil.STR_SEPARATOR);
			if (strArray.length == 2) {
				commentContent = strArray[1];
			}
		}
		return commentContent;
	}

	public void setCommentContent(String commentContent) {
		this.commentContent = commentContent;
	}

	public String getMessage() {
		return message;
	}

	public void setMessage(String message) {
		this.message = message;
	}

	public String getAgencyId() {
		return agencyId;
	}

	public void setAgencyId(String agencyId) {
		this.agencyId = agencyId;
	}

	public String getDepartmentId() {
		return departmentId;
	}

	public void setDepartmentId(String departmentId) {
		this.departmentId = departmentId;
	}

	public String getExecutionId() {
		return executionId;
	}

	public void setExecutionId(String executionId) {
		this.executionId = executionId;
	}

	public String getTransitionName() {
		return transitionName;
	}

	public void setTransitionName(String transitionName) {
		this.transitionName = transitionName;
	}

}
